package com.rongc.client.freight.business.mine.view.activity;

import android.text.Html;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.rongc.client.core.exception.RegexException;
import com.rongc.client.core.utils.ActivityUtils;
import com.rongc.client.core.utils.RegexUtil;
import com.rongc.client.freight.R;
import com.rongc.client.freight.base.BaseActivity;

import butterknife.Bind;
import butterknife.OnClick;

/**
 * Created by ccqx on 2017/7/17.
 */

public class BankAddActivity extends BaseActivity implements View.OnClickListener{
    @Bind(R.id.et_name)
    EditText mEtName;
    @Bind(R.id.et_bank)
    EditText mEtBank;
    @Bind(R.id.et_type)
    EditText mEtType;
    @Bind(R.id.et_mobile)
    EditText mEtMobile;
    @Bind(R.id.tv_bank_tip)
    TextView mTvBankTip;

    @OnClick({R.id.btn_submit})
    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn_submit:
                try{
                    prepare();
//                    RequestManager.getInstance().call(new RegisterCodeApi(new RegisterCodeApi.RegisterCodeParams(mEtPhone.getText().toString()),
//                            respCodeListener, errorListener));
                }catch (RegexException e){
                    ActivityUtils.toast(e.getMessage());
                }
                break;
        }
    }

    void prepare() throws RegexException {
        if (!RegexUtil.checkNotNull(mEtName.getText().toString())) {
            throw new RegexException("请输入姓名");
        } else if (!RegexUtil.checkNotNull(mEtBank.getText().toString())) {
            throw new RegexException("请输入银行卡号");
        }else if (!RegexUtil.checkNotNull(mEtType.getText().toString())) {
            throw new RegexException("请输入银行卡类型");
        }else if (!RegexUtil.checkNotNull(mEtMobile.getText().toString())) {
            throw new RegexException("请输入手机号");
        }
    }

    @Override
    public void initView() {
        initToolbar(R.string.bank_title);

        mTvBankTip.setText(Html.fromHtml(String.format(getResources().getString(R.string.bank_protocol_tip))));


    }


    @Override
    public int getLayoutId() {
        return R.layout.activity_addbank;
    }
}
